#include <iostream>
#include <unistd.h>
#include <cstring>
using namespace std;
int main()
{
    int arr[2];
    pipe(arr);
    pid_t pid=fork();
    if(pid==0)
    {
        //子进程
        //write      
        close(arr[0]);
        char buf[]="#######你好#######";
        write(arr[1],buf,strlen(buf));
        close(arr[1]);
        exit(0);
    }
    //父进程
    //read
    close(arr[1]);
    char buf[1024]={0};
    size_t ret=read(arr[0],buf,1024);
    buf[ret]='\0';
    cout<<buf<<endl;
    return 0;
}
